package com.blog.service;

import com.blog.mapper.HrMapper;
import com.blog.mapper.HrRoleMapper;
import com.blog.system.Hr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @ClassName UserService
 * @Destription
 * @Author 天堂小野花
 * @Date 2025/6/19  12:41
 * @Version 1.0
 */
@Service
public class HrService  {
    @Autowired
    HrMapper hrMapper;
    @Autowired
    HrRoleMapper hrRoleMapper;



    public List<Hr> getAllHrs(Integer hid,String keywords) {
        return hrMapper.getAllHrs(hid,keywords);
    }

    public Integer updateHr(Hr hr) {
        return hrMapper.updateByPrimaryKeySelective(hr);
    }

    @Transactional
    public boolean updateHrRole(Integer hrid, Integer[] rids) {
        hrRoleMapper.deleteByHrid(hrid);

        return hrRoleMapper.addRole(hrid,rids)==rids.length;
    }

    public int deleteHrById(Integer id) {
        return hrMapper.deleteByPrimaryKey(id);
    }


    public List<Hr> selectAllHr() {
        return hrMapper.selectAllHr();
    }
}
